//
//  AssociationAppDelegate.m
//  Association
//
//  Created by 一览iOS on 14-1-3.
//  Copyright (c) 2014年 job1001. All rights reserved.
//

#import "AssociationAppDelegate.h"
//#import "UMSocialWechatHandler.h"
//#import "UMSocialQQHandler.h"
#import "MyConfig.h"
#import "WXApi.h"
#import "PayCtl.h"
#import "ELJPush.h"
#import "ELBaseListCtl.h"
#import "RootTabBarViewController.h"
#import <UserNotifications/UserNotifications.h>
#import "ELFMDevice.h"
#import "ELGroupDetailCtl.h"
#import "SYSafeCategory.h"
#import "JQSafeKit.h"
#import "BaiduOAuthSDK.h"
#import <YTKNetwork.h>
#import "ELHtmlAppBridge.h"
#import "ELAppUpdateManager.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import "ELFeedbackCtl.h"
#import "ELFeedbackPagerController.h"
#import "ELAttachmentUploadManager.h"
#import <UMCommon/UMConfigure.h>
#import "ELDoubleAuthentication.h"
#import "ELRemoteNotificationManager.h"

#import "UITextViewWorkaround.h"
#import "Public.h"
#import "OpenInstallSDK.h"
//static NSString *const KTrackingID = @"UA-92066272-4";  //需要换成自己的跟踪ID
//
//static NSString *const KAllowTracking = @"allowTracking";


//debug
#import "APIDebug.h"
#import "ScreenShot.h"

#import "ELLiveBroadcastViewController.h"
#import "ELWorkProtocolCtl.h"
#import "ELPolyvLiveDetailCtl.h"
#import "TXChatServiceProvider.h"

#import "ELLiveItemModel.h"
#import "ELShortVideoModel.h"

#import "UINavigationController+WXSTransition.h"
#import "ELPlayVideoCtl.h"

@interface AssociationAppDelegate ()<WXApiDelegate,UNUserNotificationCenterDelegate,OpenInstallDelegate>

@property(nonatomic, assign)BOOL isCanclePay;
@property(nonatomic, strong) ScreenShot *screenShot;
@property (nonatomic, strong) ELAttachmentUploadManager *attachmentUploadManager;

@end

//分享回调的url
NSURL *receiveURL;
//注册推送的硬件token
NSString *deviceTokenStr;


@implementation AssociationAppDelegate

@synthesize bFromNotification = _bFromNotification;
@synthesize messageType = _messageType;

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
    if (self.allowRotation) {
        return  UIInterfaceOrientationMaskAllButUpsideDown;
    }
    return UIInterfaceOrientationMaskPortrait;
}

// 返回是否支持设备自动旋转
- (BOOL)shouldAutorotate
{
    if (self.allowRotation) {
        return YES;
    }
    return NO;
}
//应用没有加载点击通知调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    [UITextViewWorkaround executeWorkaround];
//    [TXChatServiceProvider setupCustomSticker];// 处理腾讯IM表情包
    //默认为YES
    [IQKeyboardManager sharedManager].enable = NO;
    [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
    [self judgeAppStoreVersion];//获取AppStore版本号
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    [OpenInstallSDK initWithDelegate:self];

#ifdef DEBUG
    NSLog(@"-------------->关闭友盟崩溃统计");
    NSString *umengAppKey = BetaUmengAppKey;//UMAPPKEY
//    if ([ELBundleID isEqualToString:@"com.job1001.jobClientBeta"]) {
//        umengAppKey = BetaUmengAppKey;
//    }
        // 友盟
    [UMConfigure setLogEnabled:YES];//设置打开日志
    [UMConfigure initWithAppkey:umengAppKey channel:nil];
    
#else
    [UMConfigure initWithAppkey:UMAPPKEY channel:nil];
#endif

    
    // 高德地图
//    NSString *aMapKey = ELAMapKey;
//    if ([ELBundleID isEqualToString:@"com.job1001.jobClientBeta"]) {
//        aMapKey = ELBetaAMapKey;
//    }
//    [AMapServices sharedServices].apiKey = aMapKey;
    
    // 数据安全处理
    [SYSafeCategory callSafeCategory];
    [JQSafeKit becomeEffective];
//    //监听通知:JQSafeKitNotification, 获取JQSafeKit捕获的崩溃日志的详细信息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dealwithCrashMessage:) name:JQSafeKitNotification object:nil];
    
    // YTKNetwork网络请求配置
    [self YTKNetworkConfig];
    
    //第一次加载程序
    if(![getUserDefaults(@"firstLaunch") boolValue])
    {
        //设置显示内页功能引导
        [Manager shareMgr].showModal_ = NO;
        [Manager shareMgr].showModal2_ = YES;
        //设置显示app介绍页面
        [Manager haveShowLogo:NO];
    } else{
        //设置不显示内页功能引导
        [Manager shareMgr].showModal_ = NO;
        [Manager shareMgr].showModal2_ = NO;
        //设置不显示app介绍页面
        [Manager haveShowLogo:YES];
    }
    
    self.window.backgroundColor = [UIColor whiteColor];
    //这个方法不能放后面，会把启动页干掉
    [self.window makeKeyAndVisible];
    [[Manager shareMgr] begin:self.window];
    

    //开启来电监听
    [[Manager shareMgr] startThephonecallcame];

    [self configUSharePlatforms];
    
    //用于微信支付，分享
    
#ifdef DEBUG
//    在register之前打开log, 后续可以根据log排查问题（正式环境注释）
//    [WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
//        NSLog(@"-----startLogByLevel-------》WeChatSDK: %@", log);
//    }];
    BOOL isRegisterApp = [WXApi registerApp:WXAppKey_EL universalLink:@"https://1001.job1001.com/elanApp/"];//https://1001.job1001.com/elanApp/
    //调用自检函数（正式环境注释）
//    [WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
//        NSLog(@"-----checkUniversalLinkReady-------》%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
//    }];
#else
    [WXApi registerApp:WXAppKey_EL universalLink:@"https://1001.job1001.com/elanApp/"];
#endif

    
    [Manager shareMgr].isBackstage = NO;
#pragma mark - 极光SDK实例化
    [[ELJPush pushManager] setupWithOption:launchOptions application:application];
    
    // 百度 oauth
    [BaiduOAuthSDK initWithAPIKey:BaiduOauthAppKey appId:BaiduOauthAppId];
    if (![Manager shareMgr].haveLogin) {
        [[Manager shareMgr] baiduLogout];
    }
    
    //开启网络监听
    [self AFNReachabilityMonitoring];
    
//#pragma mark - 测试推送铃声
//    [self addLocalNotification];
    
    // 更新数据库及相关文件
//    [self updateDatabaseAndFiles];
    
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
    
    // 听云
//    NSString *userId = StringIsNotEmpty([Manager getUserInfo].userId_) ? [Manager getUserInfo].userId_ : @"unLogin";
//    NSString *phoneNum = StringIsNotEmpty([Manager getUserInfo].mobile_) ? [Manager getUserInfo].mobile_ : @"";
//    [NBSAppAgent setUserIdentifier:userId];
//    [NBSAppAgent setCustomerData:userId forKey:@"userId"];
//    [NBSAppAgent setCustomerData:phoneNum forKey:@"phoneNum"];

    // 截屏反馈
    [self startJiePingFanKui];
    
    
    //双因子认证// @"超过7天登录时间，需要重新登录";
    if ([Manager checkLogin]){
        ELDoubleAuthentication * doublecheck = [ELDoubleAuthentication sharedDoubleAuthentication];
        [doublecheck doubleCheckLogin:@"normal" success:^(bool result,NSInteger code) {
            if (result == YES){
                // @"7天登录时间已过，需要重新登录";
                NSString *msg = @"登录信息已失效，请重新登录";
                UIAlertController *alertCtl = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
                [alertCtl addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                    [[NSUserDefaults standardUserDefaults] setObject:@"normal" forKey:@"DoubleAuthentication"];
                    [[Manager shareMgr] loginOut];
                    [Manager shareMgr].haveLogin = NO;
                    [[Manager shareMgr].myCenterCtl reload];
                }]];
                [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alertCtl animated:NO completion:nil];
            }
        } failure:^(NSError *error) {

        }];
    }
    
    
    return YES;
}

- (void)confitUShareSettings
{
    /*
     * 打开图片水印
     */
    //[UMSocialGlobal shareInstance].isUsingWaterMark = YES;
    /*
     * 关闭强制验证https，可允许http图片分享，但需要在info.plist设置安全域名
     <key>NSAppTransportSecurity</key>
     <dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
     </dict>
     */
    //[UMSocialGlobal shareInstance].isUsingHttpsWhenShareContent = NO;
}

- (void)configUSharePlatforms {
//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//        UIImage *emojiImage = [[PLVEmoticonManager sharedManager] imageForEmoticonName:emojiModel.imageName];
//        dispatch_async(dispatch_get_main_queue(), ^{
//            cell.imageView.image = emojiImage;
//        });
//    });
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//    dispatch_async(dispatch_get_main_queue(), ^(){
        /* 设置微信的appKey和appSecret */
        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:WXAppKey_EL appSecret:WXAppSecret_EL redirectURL:@"http://mobile.umeng.com/social"];
        /*
         * 移除相应平台的分享，如微信收藏
         */
        //[[UMSocialManager defaultManager] removePlatformProviderWithPlatformTypes:@[@(UMSocialPlatformType_WechatFavorite)]];
        /* 设置分享到QQ互联的appID
         * U-Share SDK为了兼容大部分平台命名，统一用appKey和appSecret进行参数设置，而QQ平台仅需将appID作为U-Share的appKey参数传进即可。
         */
        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:QQAppKey_EL appSecret:QQAppSecret_EL redirectURL:@"http://mobile.umeng.com/social"];
        
    //    /* 设置新浪的appKey和appSecret */
        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:SinaAppKey_EL  appSecret:SinaAppSecret_EL redirectURL:@"https://sns.whalecloud.com/sina2/callback"];
        
        /* 钉钉的appKey */
        NSString *dingdingAppKey = DingdingAppKey_EL;
        if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"] isEqualToString:@"com.job1001.jobClientBeta"]) {
            dingdingAppKey = DingdingAppKey_EL_Beta;
        }
        [[UMSocialManager defaultManager] setPlaform: UMSocialPlatformType_DingDing appKey:dingdingAppKey appSecret:nil redirectURL:nil];
    });
    
    
}

#pragma mark - 更新数据库及相关文件
- (void)updateDatabaseAndFiles {
    [ELRegionManager installELKKProvinceDatas];
    [ELRegionManager installELKKCityDatas];
    [ELRegionManager installELKKAreaDatas];
    // 安卓数据
    [ELRegionManager installCityJsonDatasForAndroid];
}

#pragma mark - YTKNetwork网络配置
- (void)YTKNetworkConfig {
    YTKNetworkConfig *networkConfig = [YTKNetworkConfig sharedConfig];
    networkConfig.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
}

//打印奔溃信息
void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}

- (void)dealwithCrashMessage:(NSNotification *)note {
    //注意:所有的信息都在userInfo中
    //你可以在这里收集相应的崩溃信息进行相应的处理(比如传到自己服务器)
    NSLog(@"\n\n在AppDelegate中 方法:dealwithCrashMessage打印\n\n\n\n\n%@\n\n\n\n",note.userInfo);
}

#pragma mark 添加本地通知
/*
-(void)addLocalNotification{
    
    //定义本地通知对象
    UILocalNotification *notification=[[UILocalNotification alloc]init];
    //设置调用时间
    notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:10.0];//通知触发的时间，10s以后
    notification.repeatInterval=8;//通知重复次数
    //notification.repeatCalendar=[NSCalendar currentCalendar];//当前日历，使用前最好设置时区等信息以便能够自动同步时间
    
    //设置通知属性
    notification.alertBody=@"最近添加了诸多有趣的特性，是否立即体验？"; //通知主体
    notification.applicationIconBadgeNumber=1;//应用程序图标右上角显示的消息数
    notification.alertAction=@"打开应用"; //待机界面的滑动动作提示
    notification.alertLaunchImage=@"Default";//通过点击通知打开应用时的启动图片,这里使用程序启动图片
    //notification.soundName=UILocalNotificationDefaultSoundName;//收到通知时播放的声音，默认消息声音
    notification.soundName=@"msg.caf";//通知声音（需要真机才能听到声音）
    
    //设置用户信息
    notification.userInfo=@{@"id":@1,@"user":@"Kenshin Cui"};//绑定到通知上的其他附加信息
    
    //调用通知
    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
*/

- (void)AFNReachabilityMonitoring
{
    //有点神奇，人才端会自动触发网络监听，其他端不会，导致网络无法请求
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusNotReachable:{
                NSLog(@"-----------无网络---------");
            }
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:{
                NSLog(@"-----------WiFi网络-------");
                [Manager removeNoNetworkView];
            }
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:{
                NSLog(@"-----------无线网络-------");
                [Manager removeNoNetworkView];
            }
                break;
            default:
                break;
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:@"setReachabilityStatusChangeNotify" object:nil userInfo:@{@"status": @(status).stringValue}];
    }];
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    //记录home时间戳
    NSDate* dat = [[NSDate alloc]init];
    NSString *strDate = [dat stringWithFormatDefault];
    NSUserDefaults *homeDefaults = [[NSUserDefaults alloc]init];
    [homeDefaults setObject:strDate forKey:@"HOMETIMEUSERDEFAULT"];    
}

#pragma mark - APPEnterForeground
- (void)applicationWillEnterForeground:(UIApplication *)application
{
//    [application setApplicationIconBadgeNumber:0];
    dispatch_async(dispatch_get_main_queue(), ^(){
        [application cancelAllLocalNotifications];
    });
    

    _isCanclePay = NO;
    [self checkOrderIsPayed];

    if (self.backgroundTaskIdentifier != UIBackgroundTaskInvalid){
        [self endBackgroundTask];
    }

//    [[Manager shareMgr] checkIfResetPassword]; 19-01-07弃用
    
    if ( StringIsEmpty([Manager getUserInfo].bindCompanyId)) {
         [[Manager shareMgr] checkIfCompanyAccountUnbound];
    }
}


#pragma mark - APPEnterBackground
- (void)applicationDidEnterBackground:(UIApplication *)application
{
#pragma mark-- 谷歌分析在进入后台后发送数据
//    [self sendHitsInBackground];

    
//    [Manager shareMgr].appState = APPEnterForMessage;
    //语音后台无限时间播放
    if ([self isMultitaskingSupported] == NO){
        return;
    }
    self.myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f
                                                    target:self
                                                  selector:@selector(timerMethod:) userInfo:nil
                                                   repeats:YES];
    self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^(void) { [self endBackgroundTask];
    }];
    _bFromNotification = NO;
    //记录home时间戳
    NSDate* dat = [[NSDate alloc]init];
    NSString *strDate = [dat stringWithFormatDefault];
    NSUserDefaults *homeDefaults = [[NSUserDefaults alloc]init];
    [homeDefaults setObject:strDate forKey:@"HOMETIMEUSERDEFAULT"];
    
//    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"APPENTERBACKGROUPDSUCCESS" object:nil];
}

- (void) endBackgroundTask{
    dispatch_queue_t mainQueue = dispatch_get_main_queue();
    __weak AssociationAppDelegate *weakSelf = self;
    dispatch_async(mainQueue, ^(void) {
        AssociationAppDelegate *strongSelf = weakSelf;
        if (strongSelf != nil){
            [strongSelf.myTimer invalidate];
            [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskIdentifier];
            strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid; }
    });
}

- (BOOL) isMultitaskingSupported{
    BOOL result = NO;
    if ([[UIDevice currentDevice]
         respondsToSelector:@selector(isMultitaskingSupported)]){ result = [[UIDevice currentDevice] isMultitaskingSupported];
    }
    return result;
}

- (void) timerMethod:(NSTimer *)paramSender{
    NSTimeInterval backgroundTimeRemaining =
    [[UIApplication sharedApplication] backgroundTimeRemaining];
    if (backgroundTimeRemaining == DBL_MAX){ NSLog(@"Background Time Remaining = Undetermined");
    }
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    
//    [application setApplicationIconBadgeNumber:0];
//    [application cancelAllLocalNotifications];

//    [Manager shareMgr].appState = APPEnterAPPCon;
    __block int timeout=1;//倒计时时间
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
    dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
    dispatch_source_set_event_handler(_timer, ^{
        if(timeout<=0){ //倒计时结束，关闭
            dispatch_source_cancel(_timer);
            dispatch_async(dispatch_get_main_queue(), ^{
                if ([[MyCommon getEnterBackgroundStatus] isEqualToString:@"1"]) {
                    [MyCommon setEnterBackgroundStatus:@"0"];
                }
            });
        }else{
            timeout--;
        }
    });
    dispatch_resume(_timer);
//    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    [Manager shareMgr].messageCnt_ = 0;
//    [[Manager shareMgr] openApp3GPushCtl];
    [ELHtmlAppBridge handleUrl:[Manager shareMgr].openAppUrl isOpenAppByOthers:YES];
//    [[Manager shareMgr] testOpenAppWithJsonData];
    
    // 接口测试
    [APIDebug testApiDebug];
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    [MyCommon setEnterBackgroundStatus:@"1"];
    BOOL showTip = [[NSUserDefaults standardUserDefaults] boolForKey:@"showTip"];
    if (showTip) {//第三方登录完善信息关闭程序时
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showTip"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        [[Manager shareMgr] loginOut];
        [Manager shareMgr].haveLogin = NO;
    }
}


-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    // 注册deviceToken
    [[ELJPush pushManager] registerDeviceToken:deviceToken];
    NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
    deviceTokenStr = [token stringByReplacingOccurrencesOfString:@" " withString:@""] ;
//    deviceTokenStr = [self applicationToken:deviceToken] ;

    //将tokenStr写入本地文件中
    [MyCommon haveGetToken:deviceTokenStr];
    //收到tokenStr，设置一下
    [[Manager shareMgr] registNotificeCon:deviceTokenStr user:nil clientName:MyClientName startHour:0 endHour:24 clientVersion:Request_Version betweenHour:6];
}



// iOS13 推送的 deviceToken 获取到的格式发生变化
// 参考友盟的处理，适配新旧系统
- (NSString *)applicationToken:(NSData *)deviceToken {
    if (![deviceToken isKindOfClass:[NSData class]]) return nil;
    const unsigned *tokenBytes = [deviceToken bytes];
    NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
                          ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
                          ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
                          ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
    NSLog(@"deviceToken:%@", hexToken);
    return hexToken;
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSLog(@"didFailToRegisterForRemoteNotificationsWithError: %@", error);
}

#pragma mark - AAP后台运行此函数会被调用
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    
    
    
//    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
//    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    [[ELJPush pushManager] handleRemoteNotification:userInfo];
    [Manager shareMgr].pushViewFlag = YES;
    [ELRemoteNotificationManager shareMgr].pushViewFlag = YES;
    [[ELJPush pushManager] receiveWithUserInfo:userInfo];
    _bFromNotification = YES;
}

//#ifdef __IPHONE_7_0
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    
    //友盟统计点击数
    [[ELJPush pushManager] handleRemoteNotification:userInfo];
    
//    if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
//        return;
//    }
//    if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) {
//        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
//        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
//    }
    if ([[UIDevice currentDevice].systemVersion floatValue]<10.0 || application.applicationState>0) {
        [[ELJPush pushManager] receiveWithUserInfo:userInfo];
    }
    completionHandler(UIBackgroundFetchResultNewData);
    _bFromNotification = YES;
}
//#endif


- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    [WXApi handleOpenURL:url delegate:self];
    [BaiduOAuthSDK handleOpenURL:url];
    [MobClick handleUrl:url];
    [[UMSocialManager defaultManager] handleOpenURL:url];
    return YES;

}

//iOS9及以下使用以下方法
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    [[UMSocialManager defaultManager] handleOpenURL:url];
    NSString *urlStr = [NSString stringWithFormat:@"%@",url];
    NSLog(@"其他App分享文件路径：\n%@",[urlStr URLDecodedForString]);
//    if ([urlStr containsString:@"Documents/Inbox/"] || [urlStr containsString:@"-Inbox/"]) {
    if ([urlStr containsString:@"Inbox/"]) {//附件简历上传
        NSLog(@"------->%ld----%ld",[ELKeyChainManager sharedManager].loginIdentityType,ELLoginIdentityTypePerson);
        if ([ELKeyChainManager sharedManager].loginIdentityType != ELLoginIdentityTypePerson) {
            return YES;
        }
        [self.attachmentUploadManager receiveAttachmentWithDocumentFilePath:urlStr];//文件共享（附件简历）
        return YES;
    }
    
    _isCanclePay = YES;
    NSLog(@"%@----%@---%@", url.host,url.absoluteString,url.relativeString);
    if ([url.host isEqualToString:@"pay"]) {//微信支付
        return [WXApi handleOpenURL:url delegate:self];
    }
    if ([WXApi handleOpenURL:url delegate:self]) {
        return YES;
    }
    if ([url.host isEqualToString:@"percenter"])
    {
        NSDictionary *queryDic = [PayCtl parseQueryString:url.query];
        NSString *userId = queryDic[@"pid"];
        
        ELPersonHomePageCtl * ctl =[ELPersonHomePageCtl new];
        ctl.toPersonId = userId;//14981889 -23150821
        [[Manager shareMgr].centerNav_ pushViewController:ctl animated:YES];
        
        return YES;
    }
    if ([url.host isEqualToString:@"group"])//社群，打开社群详情
    {
        NSDictionary *queryDic = [PayCtl parseQueryString:url.query];
        NSString *groupId = queryDic[@"gip"];
        ELGroupDetailCtl *detailCtl = [[ELGroupDetailCtl alloc]init];
        Groups_DataModal *dataModal = [[Groups_DataModal alloc] init];
        dataModal.id_ = groupId;
        [[Manager shareMgr].centerNav_ pushViewController:detailCtl animated:YES];
        [detailCtl beginLoad:dataModal exParam:nil];
        return YES;
    }
    if ([url.absoluteString containsString:@"yl1001jobClient"] || [url.absoluteString containsString:@"scme201810316192072702271d"]){
        if ([url.absoluteString containsString:@"type=alipays"]) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"AlipaysFinishNotification" object:nil userInfo:@{@"url":url.absoluteString}];
        }else{
            [Manager shareMgr].openAppUrl = url.absoluteString;
        }
        return YES;
    }
    if ([url.absoluteString containsString:@"baidu"]) {
        return [BaiduOAuthSDK handleOpenURL:url];
    }
    if ([url.absoluteString containsString:@"platformId=wechat"]){//小程序唤起微信
        return [WXApi handleOpenURL:url delegate:self];
    }
    
    [MobClick handleUrl:url];
    
    [OpenInstallSDK handLinkURL:url];
//    [BaseUIViewController showAutoDismissFailView:nil msg:@"携带参数1111111" seconds:5.0];
    return YES;
}
//iOS9以上，会优先走这个方法
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(nonnull NSDictionary *)options{
    
    [OpenInstallSDK handLinkURL:url];
    [[UMSocialManager defaultManager] handleOpenURL:url];
    NSString *urlStr = [NSString stringWithFormat:@"%@",url];
//    [BaseUIViewController showAutoDismissFailView:nil msg:@"携带参数2222222" seconds:5.0];
    if ([urlStr containsString:@"Inbox/"]) {//附件简历上传
        NSLog(@"------->%ld----%ld",[ELKeyChainManager sharedManager].loginIdentityType,ELLoginIdentityTypePerson);
        if ([ELKeyChainManager sharedManager].loginIdentityType != ELLoginIdentityTypePerson) {
            return YES;
        }
        [self.attachmentUploadManager receiveAttachmentWithDocumentFilePath:urlStr];//文件共享（附件简历）
        return YES;
    }
    
    if ([urlStr containsString:[NSString stringWithFormat:@"%@://pay",WXAppId]]) {
        return [WXApi handleOpenURL:url delegate:self];
    }
    
    return YES;
}
#pragma mark - ---------->外部链接唤醒App
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable restorableObjects))restorationHandler {
    [WXApi handleOpenUniversalLink:userActivity delegate:self];
    [OpenInstallSDK continueUserActivity:userActivity];
//    [BaseUIViewController showAutoDismissFailView:nil msg:@"携带参数333333" seconds:5.0];
    return YES;
}
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity  API_AVAILABLE(ios(13.0)){
    [WXApi handleOpenUniversalLink:userActivity delegate:self];
    [OpenInstallSDK continueUserActivity:userActivity];
//    [BaseUIViewController showAutoDismissFailView:nil msg:@"携带参数444444" seconds:5.0];
}
//sceneDelegate.m中
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions  API_AVAILABLE(ios(13.0)){
    //最好先加载完UI代码[self.window makeKeyAndVisible];
    //通用链接相关代码，用于App被杀死后一键拉起后传递动态参数
    for (NSUserActivity *userActivity in connectionOptions.userActivities) {
        [OpenInstallSDK continueUserActivity:userActivity];
//        [BaseUIViewController showAutoDismissFailView:nil msg:@"携带参数555555" seconds:5.0];
    }
}
//scheme相关代码
- (void)scene:(UIScene *)scene openURLContexts:(NSSet *)URLContexts API_AVAILABLE(ios(13.0)){
    for (UIOpenURLContext *urlcontext in URLContexts){
        [OpenInstallSDK handLinkURL:urlcontext.URL];
//        [BaseUIViewController showAutoDismissFailView:nil msg:@"携带参数6666666" seconds:5.0];
    }
}
/*
#pragma mark - 通过其他App导入文件
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options
{
    NSString *urlStr = [NSString stringWithFormat:@"%@",url];
    NSLog(@"其他App分享文件路径：\n%@",[urlStr URLDecodedForString]);
//    if ([urlStr containsString:@"Documents/Inbox/"] || [urlStr containsString:@"-Inbox/"]) {
    if ([urlStr containsString:@"Inbox/"]) {
        if ([ELKeyChainManager sharedManager].loginIdentityType != ELLoginIdentityTypePerson) {
            return YES;
        }
        [self.attachmentUploadManager receiveAttachmentWithDocumentFilePath:urlStr];
        return YES;
    }
    
    _isCanclePay = YES;
    NSLog(@"%@----%@---%@", url.host,url.absoluteString,url.relativeString);

    if ([url.host isEqualToString:@"pay"]) {//微信支付
        return [WXApi handleOpenURL:url delegate:self];
    }else if ([url.host isEqualToString:@"percenter"])
    {
        NSDictionary *queryDic = [PayCtl parseQueryString:url.query];
        NSString *userId = queryDic[@"pid"];
        ELPersonCenterCtl *ctl = [[ELPersonCenterCtl alloc] init];
        //        [self.navigationController pushViewController:ctl animated:YES];
        [ctl beginLoad:userId exParam:nil];
    }else if ([url.host isEqualToString:@"group"])//社群，打开社群详情
    {
        NSDictionary *queryDic = [PayCtl parseQueryString:url.query];
        NSString *groupId = queryDic[@"gip"];
        ELGroupDetailCtl *detailCtl = [[ELGroupDetailCtl alloc]init];
        Groups_DataModal *dataModal = [[Groups_DataModal alloc] init];
        dataModal.id_ = groupId;
        //        [self.navigationController pushViewController:detailCtl animated:YES];
        [detailCtl beginLoad:dataModal exParam:nil];
    }else if ([url.absoluteString containsString:@"yl1001jobClient"]){
        if ([url.absoluteString containsString:@"type=alipays"]) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"AlipaysFinishNotification" object:nil userInfo:@{@"url":url.absoluteString}];
        }else{
            [Manager shareMgr].openAppUrl = url.absoluteString;
        }
    } else if ([url.absoluteString containsString:@"baidu"]) {
        return [BaiduOAuthSDK handleOpenURL:url];
    }
    else {
        return  [[UMSocialManager defaultManager] handleOpenURL:url];
    }
    return YES;
}
*/

- (ELAttachmentUploadManager *)attachmentUploadManager {
    if (!_attachmentUploadManager) {
        _attachmentUploadManager = [[ELAttachmentUploadManager alloc] init];
    }
    return _attachmentUploadManager;
}


#pragma mark 微信支付返回的结果
- (void)onResp:(BaseResp *)resp
{
    if ([resp isKindOfClass:[PayResp class]]) {
        NSString *strTitle = [NSString stringWithFormat:@"支付结果"];
        NSString *strMsg = nil;
        if (resp.errCode == 0) {
            strMsg = @"支付成功";
        }else if (resp.errCode == -1) {
            strMsg = @"支付异常，请查看订单详情";
        }else if (resp.errCode == -2) {
            strMsg = @"支付被取消";
        }
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle
                                                            message:strMsg
                                                           delegate:self
                                                  cancelButtonTitle:@"确定"
                                                  otherButtonTitles:nil, nil];
        if ([Manager shareMgr].payType == PayTypeReward) {
            if (resp.errCode != 0) {
                [alert show];
            }
        }
        else
        {
            [alert show];
        }
        
        if (resp.errCode == 0) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"WX_PAY_SUCCESS" object:nil userInfo:@{@"errCode":@(resp.errCode)}];
        } else {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"WX_PAY_FAIL" object:nil userInfo:@{@"errCode":@(resp.errCode),@"errInfo":strMsg}];
        }
    }
    
    if ([resp isKindOfClass:[WXLaunchMiniProgramResp class]]) {//小程序唤起App
        [[NSNotificationCenter defaultCenter] postNotificationName:@"WXLaunchMiniProgramResp" object:nil];
    }
}

#pragma mark - Status bar touch tracking
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    CGPoint location = [[[event allTouches] anyObject] locationInView:[self window]];
    CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
    if (CGRectContainsPoint(statusBarFrame, location)) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"statusBarTouchedAction" object:nil];
    }
}

#pragma mark - 订单处理

- (void)checkOrderIsPayed
{
    NSString *orderId = getUserDefaults(@"WX_PAY");
    if (orderId.length > 0) {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (!_isCanclePay) {
                [self requestOrderStatus:orderId];
            }
        });
    }
}

- (void)requestOrderStatus:(NSString *)orderId
{
    CommonRequestModel *model = [[CommonRequestModel alloc] init];
    [model getOrderStatus:orderId];
    [HPNetworking postWithModel:model succeed:^(id  _Nullable result) {
        if ([result isKindOfClass:[NSDictionary class]]) {
            
            if ([result[@"code"] isEqualToString:@"200"]) {
//                [[NSNotificationCenter defaultCenter] postNotificationName:@"WX_PAY_SUCCESS" object:nil userInfo:@{@"errCode":@(0)}];
                //结束后 清空
                kUserDefaults(@"", @"WX_PAY");
                kUserSynchronize;
            } else {
                [[NSNotificationCenter defaultCenter] postNotificationName:@"WX_PAY_FAIL" object:nil userInfo:@{@"errCode":@([[result objectForKey:@"code"] integerValue]),@"errInfo":[result objectForKey:@"status_desc"]}];
            }
        }
    } failure:^(NSString * _Nullable error) {
        
    }];
}

#pragma mark - 截屏反馈
- (void)startJiePingFanKui{
    if (self.screenShot) {
        return;
    }
    // 190603 - 提审时被拒。苹果已有自己的截图交互，表示此操作不符合iOS人机界面交互
    if (![MyCommon isOutOfReview]) {
        return ;
    }
    
    if ([ELKeyChainManager sharedManager].loginIdentityType != ELLoginIdentityTypePerson && [ELKeyChainManager sharedManager].loginIdentityType != ELLoginIdentityTypeEnterprise) {
        return;
    }
    
    self.screenShot = [[ScreenShot alloc] init];
    _screenShot.tapHandle = ^(UIImage * _Nonnull image) {
        ELFeedbackPagerController *ctl = [[ELFeedbackPagerController alloc] init];
        ctl.image = image;
        ctl.hidesBottomBarWhenPushed = YES;
        [[Manager shareMgr].centerNav_ pushViewController:ctl animated:YES];
    };
}

#pragma mark - ---------->//通过OpenInstall获取已经安装App被唤醒时的参数（如果是通过渠道页面唤醒App时，会返回渠道编号）
-(void)getWakeUpParams:(OpeninstallData *)appData{
    if (appData.data) {//(动态唤醒参数)
        //e.g.如免填邀请码建立邀请关系、自动加好友、自动进入某个群组或房间等
        NSDictionary *dict = appData.data;
        NSString *enterType = [dict objectForKey:@"enterType"];
        if (StringIsNotEmpty(enterType)) {
            [self uploadWakeParam:dict];
        }
        if ([Manager shareMgr].haveLogin && [ELKeyChainManager sharedManager].loginIdentityType == ELLoginIdentityTypePerson && StringIsNotEmpty(enterType)) {
            if ([enterType isEqualToString:@"brokerPage"]) {//个人主页（自己/别人）
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *toPersonId = [param objectForKey:@"consultId"];
                
                if (StringIsNotEmpty(toPersonId)) {
                    ELPersonHomePageCtl * ctl =[ELPersonHomePageCtl new];
                    ctl.toPersonId = toPersonId;//14981889 -23150821
                    [CurrentNavigation pushViewController:ctl animated:YES];
                }
                return;
            }
            
            if ([enterType isEqualToString:@"articleDetail"]) {//职讯详情
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *articleId = [param objectForKey:@"articleId"];
                
                if (StringIsNotEmpty(articleId)) {
                    ArticleDetailCtl* contentDetailCtl = [[ArticleDetailCtl alloc] init];
                    contentDetailCtl.type_ = @"1";
                    
                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                        [CurrentNavigation pushViewController:contentDetailCtl animated:YES];
                        [contentDetailCtl beginLoad:articleId exParam:nil];
                    });
                    
                }
                return;
            }
            
            if ([enterType isEqualToString:@"liveDetail"]) {
                [ELMobClick event:@"Person_Live_JobFair"];//友盟埋点
                
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *liveId = [NSString stringWithFormat:@"%@",[param objectForKey:@"liveId"]];
                
                if (StringIsNotEmpty(liveId)) {
                    ELLiveBroadcastViewController *ctl = [[ELLiveBroadcastViewController alloc]init];
                    ctl.live_id = liveId;
                    [CurrentNavigation pushViewController:ctl animated:YES];
                }
                return;
            }
            
            if ([enterType isEqualToString:@"applyBrokerPage"]) {//申请职业顾问
            
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *toPersonId = [param objectForKey:@"person_id"];
                if ([toPersonId isEqualToString:[Manager getUserInfo].userId_]) {
                    NSString* vcId = @"ELWorkProtocolCtl";
                    [CurrentNavigation pushViewController:getCtlWithSb(SbWorkBroker, vcId) animated:YES];
                }else{
                    [BaseUIViewController showAutoDismissFailView:nil msg:@"请检查是否登录账号一致？" seconds:3.0];
                }
                return;
            }
            if ([enterType isEqualToString:@"setBrokerPage"]) {//个人主页
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *toPersonId = [param objectForKey:@"person_id"];
                if ([toPersonId isEqualToString:[Manager getUserInfo].userId_]) {
                    ELPersonHomePageCtl * ctl =[ELPersonHomePageCtl new];
                    ctl.toPersonId = toPersonId;//14981889 -23150821
                    [CurrentNavigation pushViewController:ctl animated:YES];
                }else{
                    [BaseUIViewController showAutoDismissFailView:nil msg:@"请检查是否登录账号一致？" seconds:3.0];
                }
                return;
            }
            if ([enterType isEqualToString:@"brokerPageList"]) {//顾问列表
                
                RootTabBarViewController *tabVC = [Manager shareMgr].tabVC;
                [tabVC showControllerIndex:1];
                [tabVC.tabBarView showControllerIndex:1];
                
                [[NSNotificationCenter defaultCenter] postNotificationName:@"CAREERGUIDESELECTINDEX" object:@{@"index":@"4"}];
                
                return;
            }
            if ([enterType isEqualToString:@"polyvListPage"]) {//直播列表

                RootTabBarViewController *tabVC = [Manager shareMgr].tabVC;
                [tabVC showControllerIndex:1];
                [tabVC.tabBarView showControllerIndex:1];
                
                [[NSNotificationCenter defaultCenter] postNotificationName:@"CAREERGUIDESELECTINDEX" object:@{@"index":@"3"}];
                
                return;
            }
            if ([enterType isEqualToString:@"polyvMajorIdlPage"]) {//直播列表
                
                RootTabBarViewController *tabVC = [Manager shareMgr].tabVC;
                [tabVC showControllerIndex:1];
                [tabVC.tabBarView showControllerIndex:1];
                
                [[NSNotificationCenter defaultCenter] postNotificationName:@"CAREERGUIDESELECTINDEX" object:@{@"index":@"3"}];
                
                return;
            }
            if ([enterType isEqualToString:@"polyvDetailPage"]) {//直播预约详情
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *liveId = [param objectForKey:@"liveId"];
                
                ELPolyvLiveDetailCtl *ctl = [[ELPolyvLiveDetailCtl alloc]init];
                ctl.liveId = liveId;
                [CurrentNavigation pushViewController:ctl animated:YES];
                
                return;
            }
            if ([enterType isEqualToString:@"polyvLiveDetailPage"]) {// 保利威直播播放页----（直播详情返回的字段）
                NSDictionary *param = [dict objectForKey:@"param"];
                
                ELLiveItemModel *itemModel = [ELLiveItemModel mj_objectWithKeyValues:param];
//                [self startLiveTemplate:itemModel.liveStatus.intValue model:itemModel];
    
                return;
            }
            if ([enterType isEqualToString:@"shortvideo"]) {// 短视频播放页
                NSDictionary *param = [dict objectForKey:@"param"];
                
                NSString *videoId = [param objectForKey:@"articleId"];
                
                [self gotoVideoPlayWithVideoId:videoId];
                return;
            }
            if ([enterType isEqualToString:@"jobDetail"]) {// 职位详情
                NSDictionary *param = [dict objectForKey:@"param"];
                NSString *jobId = [param objectForKey:@"jobId"];
                
                
                ZWDetail_DataModal *zwVO = [ZWDetail_DataModal new];
                zwVO.zwID_ = jobId;
                
                PositionDetailCtl *ctl = [[PositionDetailCtl alloc] init];
                ctl.type_ = 1;
                ctl.sourceType = @"browse";
                [CurrentNavigation pushViewController:ctl animated:YES];
                [ctl beginLoad:zwVO exParam:nil];

                return;
            }
            
        }else{
            
            [BaseUIViewController showAutoDismissFailView:nil msg:@"请检查是否已登录账号或是否切换到求职端？" seconds:3.0];
        }
        
    }
    if (appData.channelCode) {//(通过渠道链接或二维码唤醒会返回渠道编号)
        //e.g.可自己统计渠道相关数据等
    }
//    NSLog(@"OpenInstallSDK:\n动态参数：%@;\n渠道编号：%@",appData.data,appData.channelCode);
//
//    [BaseUIViewController showAutoDismissFailView:nil msg:[NSString stringWithFormat:@"携带参数1111111：%@------%@",appData.data,appData.channelCode] seconds:5.0];
    
}

-(void)uploadWakeParam:(NSDictionary *)param{
    
    CommonRequestModel *model = [[CommonRequestModel alloc] init];
    [model uploadWithWakeParam:param];
    [HPNetworking postWithModel:model succeed:^(id  _Nullable result) {
        
        if (DictIsNotEmpty(result)) {
        
            NSDictionary *dic = result;
            NSString *code = [dic objectForKey:@"code"];
            if (code.intValue != 200) {
                [BaseUIViewController showAutoDismissFailView:nil msg:[dic objectForKey:@"status_desc"]];
            }
        }
    } failure:^(NSString * _Nullable error) {
        
    }];
    
}

-(void)gotoVideoPlayWithVideoId:(NSString *)videoId{
    
    CommonRequestModel *requestModel = [[CommonRequestModel alloc] init];
    [requestModel getVideoDetailWithVideoId:videoId];
    WS(weakSelf);
    [BaseUIViewController showLoadView:YES content:nil view:nil];
    [HPNetworking postWithModel:requestModel succeed:^(id  _Nullable result) {
        [BaseUIViewController showLoadView:NO content:nil view:nil];
        NSDictionary *dict = result;
        if (DictIsNotEmpty(dict)) {
            NSString *code = [dict objectForKey:@"code"];
            if (code.integerValue == 200) {
                ELShortVideoModel *videoModel = [ELShortVideoModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
                if (videoModel.status.integerValue == 1) {
                    [weakSelf getVideoDetailWithModel:videoModel];
                }else if (videoModel.status.integerValue == 5 || videoModel.status.integerValue == 99){
                    [BaseUIViewController showAutoDismissFailView:nil msg:@"视频审核中..."];
                }else if (videoModel.status.integerValue == 2){
                    [BaseUIViewController showAutoDismissFailView:nil msg:@"视频已删除"];
                } else {
                    [BaseUIViewController showAutoDismissFailView:nil msg:@"审核不通过/已删除：该内容因包含虚假及违规内容，为维护绿色网络环境，已停止访问"];
                }
                
            }else {
                [BaseUIViewController showAutoDismissFailView:nil msg:[dict objectForKey:@"status_desc"]];
            }
        }
    } failure:^(NSString * _Nullable error) {
        [BaseUIViewController showLoadView:NO content:nil view:nil];
    }];
    
}

-(void)getVideoDetailWithModel:(ELShortVideoModel *)model{
    
    ELPlayVideoCtl *vc = [[ELPlayVideoCtl alloc] init];
    vc.toUserId = model.ownId;
    vc.dataArray = [NSMutableArray arrayWithArray:@[model]];
    vc.page = 0;
    vc.index = 0;
    vc.isNotLoadMore = YES;
//    vc.isShowComment = YES;//弹起评论
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [CurrentNavigation wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
            transition.isSysBackAnimation = YES;
            transition.animationType = WXSTransitionAnimationTypeSpreadFromBottom;
            transition.animationTime = 0.05;
        }];
    });
    
}



- (void)judgeAppStoreVersion{
    if (![MyCommon isOutOfReview]){
        NSString *url = [NSString stringWithFormat:@"%@%@",@"https://itunes.apple.com/cn/lookup?id=",ELAppleID];
        [ELOtherHostRequest requestJavaWithMethod:@"POST" url:url params:nil success:^(id responseObj) {
            NSDictionary *appInfo = (NSDictionary *)responseObj;
            NSArray *infoContent = [appInfo objectForKey:@"results"];
            NSString *appstoreVersion = [[infoContent objectAtIndex:0] objectForKey:@"version"];
            NSString *localVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
            NSString *isShow = [NSString stringWithFormat:@"%@_%@",kIsShowHiddenFunction,localVersion];
            NSLog(@"appstoreVersion-------->%@",appstoreVersion);
            if ([ToolsClass compareVersion:appstoreVersion to:localVersion] != -1) {
                kUserDefaults(@"OK",isShow);
            }
            kUserSynchronize;
            
        } failure:^(NSError *error) {
            NSLog(@"查询iTunes应用信息错误:%@",error.description);

        }];
    }
}




#pragma mark - ---------->点赞震动
-(void)playSoundWithPath:(NSString *)soundpath{
    
    //得到音频资源的路径
    NSString *newPath = [[NSBundle mainBundle]pathForResource:soundpath ofType:@"wav"];
    //由于使用音频路径的时候为NSURL类型，所以我们需要将文件路径转换为NSURL类型
    NSURL *newurl = [NSURL fileURLWithPath:newPath];
    //需要创建一个soundID，因为播放系统声音的时候，系统找寻的是soundID，soundID的范围为1000-2000之间。
    SystemSoundID soundID;
    /*根据声音的路径创建ID    （__bridge在两个框架之间强制转换类型，值转换内存，不修改内存管理的
     权限）在转换数据类型的时候，不希望该对象的内存管理权限发生改变，原来是MRC类型，转换了还是 MRC。*/

    AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(newurl), &soundID);
    
    //播放音频
    AudioServicesPlayAlertSound(soundID);
//    添加震动，只有在iphone上才可以，模拟器没有效果。
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

   
}
@end
